<?php
/**
 *
 * Created by www.soe-soe.com
 * Author: shijy
 * Date: 2015/12/10
 * Time: 10:56
 */


function getSmarty(){
    static $smartyAdmin;
    if ($smartyAdmin) {
        return $smartyAdmin;
    }
    import('Vendor.Smarty.Smarty');
    $smartyAdmin = new Smarty();
    $smartyAdmin->template_dir = './Tpl/Wap/';
    $smartyAdmin->compile_dir = RUNTIME_PATH.'Smarty/';
    $smartyAdmin->addPluginsDir(WEB_ROOT.'/smarty_plugin');
    $smartyAdmin->caching = false;
    $smartyAdmin->left_delimiter ='<{';
    $smartyAdmin->right_delimiter='}>';
    $smartyAdmin->assign('module',MODULE_NAME);
    $smartyAdmin->assign('controller',CONTROLLER_NAME);
    $smartyAdmin->assign('action',ACTION_NAME);

    $smartyAdmin->assign('preUploadUrl',C('UPLOAD_RESOURCE_PREFIX'));//
    $smartyAdmin->assign('preStaticUrl',C('STATIC_RESOURCE_PREFIX'));//
    $smartyAdmin->assign('resVersion',RESOURCE_VERSION);//静态资源版本控制

    $smartyAdmin->assign('selfName',C('SELF_NAME'));//编辑自称，如小看，小辰辰
    $smartyAdmin->assign('plantform',CURRENT_COMPANY);//当前所属公司集团
    $smartyAdmin->assign('displayScheme',DISPLAY_SCHEME);//显示方案
    return $smartyAdmin;
}

//签到数据assign
function signAssignWap($uid,$smarty,$mySign=0){
    $isSign = session('sign')+0;
    $smarty->assign('firstTime',$isSign);
    session('sign',0);
    if($isSign <= 0){
        $isSign = $mySign;  //我的签到赋值
    }
    if($isSign > 0 && $uid && USER_HOME_MYSIGN_ENABLE){
        $signData = \Common\Model\UserModel::sign($uid,CLIENT_FROM_WAP);
        if ($signData['status'] == 0) {
            $smarty->assign('signInfo',$signData['data']['signInfo']);
            $smarty->assign('signDay',$signData['data']['signDay']);
            $smarty->assign('day',$signData['data']['weekAndDay']);
            $smarty->assign('today',date('j',time()));
            $smarty->assign('rank',$signData['data']['rank']);

            $signToast = session('signToast');
            $smarty->assign('signToast',$signToast);

        }
    }
}